package com.anlu.concurrent.ch1.safened;

/**
 * <p>
 * Description:如果安全的中断线程
 * <p>
 * Copyright: 天津联想协同科技有限公司
 * <p>
 *
 * @author anlu
 * @date 2021/9/3 16:09
 */
public class EndThread {
    private static class UseThread extends  Thread{
        public UseThread(String name) {
            super(name);
        }

        @Override
        public void run() {
            String threadName = Thread.currentThread().getName();
            while(true) {
                System.out.println(threadName+" is run!");
            }
        }
    }

    public static void main(String[] args)throws InterruptedException {
        Thread endThread = new UseThread("endThread");
        endThread.start();
        Thread.sleep(20);
        endThread.interrupt();


    }
}
